//
//  FinderItemView.swift
//  WYYao
//
//  Created by wangcl on 2024/9/10.
//

import SwiftUI
import Foundation

struct FinderItemView: View {
    var item:FinderItem
    var body: some View {
        VStack (alignment: .leading) {
            HStack {
                Image(systemName: item.isDirectory ? "folder" : "doc.text")
                Text(item.fileName).frame(minWidth: 24.0)
            }
            Spacer()
            Text(item.contentModificationDate.description(with: Locale.current)).font(.caption)
        }.padding([.top,.bottom],8.0)
    }
}

#Preview {
    let url = Bundle.main.url(
        forResource: "root_file", withExtension: "txt", subdirectory: "root")!
    let item = FinderItem(url: url)
    return List {
        FinderItemView(item: item)
    }.listStyle(.plain)
    
}
